CC = cc
CFLAG = -g
SRC = main.c scan.c expr.c tree.c cg.c gen.c stmt.c misc.c sym.c decl.c types.c
OBJ = $(SRC:.c=.o)
TARGET = comp

all: $(TARGET)

$(TARGET): $(OBJ)
	$(CC) $(CFLAG) $^ -o $@ 

%.o: %.c
	$(CC) $(CFLAG) -c $< -o $@ 

debug: CFLAG += -DDEBUG
debug: $(TARGET)

test: $(TARGET) tests/runtests.sh
	(cd tests; sh mktests.sh; sh runtests.sh)

clean:
	rm -f $(TARGET) *.o *.s out tests/out.*
